package org.rcloud.io.service.impl;

import org.rcloud.io.Utils.ResultVo;
import org.rcloud.io.mapper.RegisterMapper;
import org.rcloud.io.model.Register;
import org.rcloud.io.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Administrator on 2019/1/26.
 */
@Service(value = "registerService")
public class RegisterServiceImpl implements RegisterService {

    @Autowired
    private RegisterMapper registerMapper;

    @Override
    public ResultVo findApplyFromId(int id) {

        try {
            Register register = registerMapper.selectByPrimaryKey(id);
            return ResultVo.setOK(register);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultVo.setError(e.getMessage());
        }
    }

    @Override
    public ResultVo saveUser(Register params) {

        if (params.equals("") || params == null) {
            return ResultVo.setError("传入数据为空");
        } else {
            try {
                registerMapper.insert(params);
                return ResultVo.setOK(null);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }

    }
}
